#pragma once
#include <vector>
#include "define.h"
#include "Object.h"
#include "StateBase.h"
#include "Vector2Int.h"
#include "Camera.h"


class Object;
class StateMain : public StateBase
{
public:
	StateMain (int numCol, int numRow);
	~StateMain ();

	// State functions
	void					Update (float deltaTime);
	void					Render ();

	// Collision Detector
	Vector2Int&				ConvertToWorldPos (Vector2Int & position);
	bool					IsAvailableSpace (std::vector<Vector2Int> block, Vector2Int position);
	void					UpdateGrid (Object* object);
	
	// Game logic
	std::vector<int>		GetRowToClear ();
	int						GetNumCol () {return m_iCol;};

	// Input handler
	bool					OnKeyUp (int keycode);
	bool					OnKeyDown (int keycode);

	// Renderer
	Camera*					GetCamera();

private:
	// Collision Detector
	int**					m_grid;
	int						m_iCol, m_iRow;

	// Renderer
	Camera					m_camera;

	// Game logic
	std::vector<int>		m_rowToClear;
	std::vector<Object*>	m_object;
	Object*					m_flyer;
	bool					m_bIsClearing;
	int						m_iScore;
	int						m_iNext;
	Vector2Int				m_genPos;

	// HUD


	void					GenBlock ();
	void					CheckIfAnyRowToClear ();
	void					ClearRows ();
};
